<!--#INCLUDE FILE="..\System\Include\incAll.asp"-->
<!--#INCLUDE FILE="..\System\Include\incEvents.asp"-->
<!--#INCLUDE FILE="..\System\Include\incAuthorization.asp"-->
<!--#INCLUDE FILE="..\System\Include\incAuthentication.asp"-->
<!--#INCLUDE FILE="..\System\Include\incBanner.asp"-->
<!--#INCLUDE FILE="..\System\Include\incForm.asp"-->
<%
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::
':::  (c) 2001-2004 ExecuTRACK Software AG
':::
':::  Filename:   {PAGE_NAME}.asp
':::  Author:     {AUTHOR_NAME}
':::  Created:    {CREATION_DATE}
':::  Version:    ASP 3.0
':::
':::  Purpose:
':::    Form to add, edit and delete {TABLE_NAME}.
':::
':::  Parameters:
':::    {PAGE_KEY} - Page key for this page.
':::    {PRIMARY_KEY} - List key for list and embedded form.
':::
':::  Revision History:
':::    Author dd-mmm-yyyy Purpose
':::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Constant Declarations
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: Object name for retrieving resources and authorization.
  Const mcstrObjectName = "{PAGE_NAME}.asp"

  '::: Stored procedures that retrieve and save data for this page.
  Const mcstrSP_List = "pfrm{PAGE_NAME}_List"
  Const mcstrSP_Get  = "pfrm{PAGE_NAME}_Get"
  Const mcstrSP_Save = "pfrm{PAGE_NAME}_Save"
  Const mcstrSP_Del  = "pfrm{PAGE_NAME}_Del"

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Variable Declarations
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                            '::: -----  Page Elements  -----
  Dim mconConnection        '::: Database connection.
  Dim mintUserID            '::: Authenticated user ID.
  Dim mobjContext           '::: Object context.
  Dim mobjResourceDict      '::: ResourceDict object for fetching language-
                            '::: dependant text and other resources.
  Dim mobjPageStatus        '::: PageStatus object to hold information about
                            '::: the status of the page, like HTTP status
                            '::: and errors.
  Dim mctlPageStatusLabel   '::: Html label generated to display page status.

                            '::: -----  List Control -----
  Dim mctlList              '::: List control.
  Dim mcmdGetList           '::: ADO Command that retrieves list data.
  Dim marecList             '::: Recordset(s) for the list.
  Dim mobjListDataBinder    '::: Data binder for the list.
  Dim mobjRow               '::: Current row while looping through the list.
  Dim mintSelectedRecordID  '::: PK of the selected record in the list.

                            '::: ----- Form Control -----
  Dim mctlForm              '::: Form control.
  Dim mcmdGetForm           '::: ADO Command that retrieves form data.
  Dim mcmdSaveForm          '::: ADO Command that saves form data.
  Dim marecForm             '::: Recordset(s) for the form.
  Dim mobjFormDataBinder    '::: Data binder for the form.

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Initialize Page
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: Open database connection.
  Set mconConnection = OpenDbConnection

  '::: Authenticate the user who requested the page.
  mintUserID = AuthenticateUser(mconConnection)

  '::: Create and initialize context. It is used to pass user-related
  '::: information and ASP intrinsic objects into the EWAL components.
  Set mobjContext = NewContext(mintUserID)

  '::: Check whether the user is authorized for the page. If not, the
  '::: subroutine will redirect to a page displaying a critical error.
  AuthorizePage mobjContext, mcstrObjectName

  '::: -------------------------------------------------------------------
  '::: Resource Dictionary
  '::: -------------------------------------------------------------------
  '::: Create resource dictionary to fetch the required labels.
  Set mobjResourceDict = NewObject("ResourceDict", mobjContext)

  '::: We need resources for shared object "Form" and for the page itself.
  mobjResourceDict.AddObjectKey "Form"
  mobjResourceDict.AddObjectKey mcstrObjectName

  '::: Read resources for the given object keys into the dictionary.
  mobjResourceDict.Fill

  '::: -------------------------------------------------------------------
  '::: Page Status Object
  '::: -------------------------------------------------------------------
  '::: Create PageStatus object. It manages important information about
  '::: the state of the script such as errors and HTTP status.
  Set mobjPageStatus 				=  NewObject("PageStatus", mobjContext)
  mobjPageStatus.ObjectName =  mcstrObjectName

  '::: Set multilingual text resources for PageStatus.
  mobjPageStatus.InfoText  = mobjResourceDict("StatusTextReady")
  mobjPageStatus.ErrorText = mobjResourceDict("StatusTextError")

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Read Parameters
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: -------------------------------------------------------------------
  '::: Read Page Key(s)
  '::: --------------------------------------------------------------------
  mobjPageStatus.PageKeys.Read "{PAGE_KEY}"

  '::: Check page key is a valid record ID and is not null.
  If (Not IsRecordId(mobjPageStatus.PageKeys("{PAGE_KEY}"))) _
    Or IsNull(mobjPageStatus.PageKeys("{PAGE_KEY}")) Then
    '::: Raise critical "bad parameter" error and end script.
    mobjPageStatus.AddAppError gcintErrParameter, "{PAGE_KEY}"
    mobjPageStatus.RaiseCriticalError

  End If

  '::: -------------------------------------------------------------------
  '::: Read List Key(s)
  '::: -------------------------------------------------------------------
  If (mobjPageStatus.IsPostBack) Then
    mintSelectedRecordID = Request.Form("{PRIMARY_KEY}")

  Else
    mintSelectedRecordID = Request.QueryString("{PRIMARY_KEY}")

  End If

  '::: The selected record must be a valid record ID or Null.
  If (Not IsRecordID(mintSelectedRecordID)) Then
    '::: Raise critical "bad parameter" error and end script.
    mobjPageStatus.AddAppError gcintErrParameter, "{PRIMARY_KEY}"
    mobjPageStatus.RaiseCriticalError

  End If

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Evaluate Mode
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  EvaluateModeListForm "{PRIMARY_KEY}", mintSelectedRecordID, mobjPageStatus

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Create Form
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: In a list form, the form is only displayed when a record has been
  '::: selected by the user. If the Mode is FormNone, it is not necessary
  '::: to retrieve form data and create the form controls.
  If (mobjPageStatus.Mode <> gcintMode_FormNone) Then

    '::: Prepare stored procedure to fetch data for the form.
    Set mcmdGetForm = CreateSpCommand(mcstrSP_Get, mconConnection)
    mcmdGetForm.Parameters("@vintCurUserID").Value = mobjContext.UserId
    mcmdGetForm.Parameters("@vintCurSysLID").Value = mobjContext.LanguageId
    mcmdGetForm.Parameters("@vint{PRIMARY_KEY}").Value    = mintSelectedRecordID

    '::: Execute the stored procedure to retrieve data for the form.
    On Error Resume Next
    marecForm = OpenRecordsets(mcmdGetForm)
    If (Err.Number <> 0) Then
      '::: Error trying to fetch data. Append the ADO errors, raise a
      '::: critical "data could not be retrieved" error and end script.
      mobjPageStatus.AddAppError gcintErrDataCouldNotBeRetrieved
      mobjPageStatus.AddAdoErrors mconConnection.Errors
      mobjPageStatus.RaiseCriticalError

    End If
    On Error Goto 0

    If (mobjPageStatus.Mode <> gcintMode_FormAdd) _
      And (mobjPageStatus.Mode <> gcintMode_SubmitAdd) Then
      '::: Check the record count. Exactly one record is expected.
      If (marecForm(0).RecordCount <> 1) Then
        '::: Raise critical "wrong no. of records" error and end script.
        mobjPageStatus.AddAppError gcintErrDataWrongRecordCount, "1", CStr(marecForm(0).RecordCount)
        mobjPageStatus.RaiseCriticalError

      End If

    End If

    '::: Create the form control.
    Set mctlForm = NewObject("FormControl", mobjContext)
    mctlForm.ID = "frm{PAGE_NAME}"

    '::: Create a data binder for the form.
    Set mobjFormDataBinder = NewObject("FormDataBinder", mobjContext)
    Set mobjFormDataBinder.DataSource = marecForm(0)
    Set mobjFormDataBinder.Form = mctlForm
    Set mobjFormDataBinder.PageStatus = mobjPageStatus
    mobjFormDataBinder.Authorization.ObjectName = mcstrObjectName

    '::: -----------------------------------------------------------------
    '::: Create form controls
    '::: -----------------------------------------------------------------

    '::: Create hidden field for list key.
    mobjFormDataBinder.CreateBoundHiddenControl "{PRIMARY_KEY}"

    '::: Type of object created for bound controls is automatically
    '::: inferred from datatype of the database field in the data source.    
    {ASP_CREATE_CONTROL}

    '::: -----------------------------------------------------------------
    '::: Call BindFromDataSource to copy values from DataSource to controls.
    '::: -----------------------------------------------------------------
    '::: If a row security violation is detected when bindng data,
    '::: an error is entered into PageStatus and RaiseCriticalError is called.
    mobjFormDataBinder.BindFromDataSource

    '::: -----------------------------------------------------------------
    '::: Retrieve resource texts for controls, captions and buttons
    '::: -----------------------------------------------------------------
    AssignFormResources mctlForm, mobjResourceDict

  End If '::: Create Form

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Save Data
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: This page is re-entrant. It posts back to itself when the form is
  '::: submitted to save the data to the database.
  ':::
  '::: Note that there is no condition to check mobjPageStatus.HasErrors.
  '::: If a non-critical error has occurred, a BindFromPostBack must still be
  '::: executed so that the values entered by the user are read back into
  '::: the controls so that these values are not lost.
  If (mobjPageStatus.Mode = gcintMode_SubmitEdit) _
    Or (mobjPageStatus.Mode = gcintMode_SubmitAdd) _
    Or (mobjPageStatus.Mode = gcintMode_SubmitDelete) Then
    '::: Read the values entered by the user back into the controls.
    '::: If the structure of the passed data does not match the
    '::: controls on the form or if a row security violation is
    '::: detected, an error is entered into PageStatus.
    mobjFormDataBinder.BindFromPostBack

    '::: If no errors have occurred, then continue saving data.
    If (Not mobjPageStatus.HasErrors) Then

      '::: There are two stored procedures for saving changes:
      '::: 1) A Save SP to insert a new record/update an existing record;
      '::: 2) A Delete SP to delete an existing record.
      '::: Check the mode to determine which SP to execute.
      If (mobjPageStatus.Mode = gcintMode_SubmitEdit) _
        Or (mobjPageStatus.Mode = gcintMode_SubmitAdd) Then

        '::: Prepare stored procedure (ADO command) to save the data.
        Set mcmdSaveForm = CreateSpCommand(mcstrSP_Save, mconConnection)

        '::: Copy values of the form controls and key fields to the ADO
        '::: command parameters. ADO parameters are strongly typed so
        '::: assigning values can cause errors. Error handling is required.
        On Error Resume Next
        mcmdSaveForm.Parameters("@vintCurUserID").Value = mobjContext.UserId
        mcmdSaveForm.Parameters("@vintCurSysLID").Value = mobjContext.LanguageId
        mcmdSaveForm.Parameters("@rint{PRIMARY_KEY}").Value    = mintSelectedRecordID
        mcmdSaveForm.Parameters("@vint{PAGE_KEY}").Value       = mobjPageStatus.PageKeys("{PAGE_KEY}")
        {ASP_SAVE_PARAMETER}

        If (Err.Number <> 0) Then
          '::: Raise error that submitted data cannot be passed to the SP.
          mobjPageStatus.AddAppError gcintErrSpParameterAssignment
          '::: Append original VBScript error message for more information.
          mobjPageStatus.AddVbsError Err

        End If
        On Error Goto 0

        '::: If no errors have occurred, then continue saving data.
        If (Not mobjPageStatus.HasErrors) Then
          '::: Execute the Save SP, with error handling of course.
          On Error Resume Next
          '::: Syntax: cmd.Execute <RecAffected>, <Parameters>, <Options>
          mcmdSaveForm.Execute , , adExecuteNoRecords
          If (Err.Number <> 0) Then
            '::: Raise "data could not be saved" error. Append ADO errors.
            mobjPageStatus.AddAppError gcintErrDataCouldNotBeSaved
            mobjPageStatus.AddAdoErrors mconConnection.Errors

          End If
          On Error Goto 0

          '::: Check whether a new record has been inserted.
          If (Not mobjPageStatus.HasErrors) _
            And (mobjPageStatus.Mode = gcintMode_SubmitAdd) Then
              '::: Get ID of the new record from SP's output parameter.
              mintSelectedRecordID = mcmdSaveForm.Parameters("@rint{PRIMARY_KEY}").Value
              mctlForm.GetControl("{PRIMARY_KEY}").Value = mintSelectedRecordID

          End If

        End If
        '::: End of (Mode = SubmitAdd/SubmitEdit)

      ElseIf (mobjPageStatus.Mode = gcintMode_SubmitDelete) Then
        '::: Prepare stored procedure (ADO command) to delete the record.
        Set mcmdSaveForm = CreateSpCommand(mcstrSP_Del, mconConnection)

        '::: Copy values of key fields to the ADO command parameters.
        '::: Error handling is required
        On Error Resume Next
        mcmdSaveForm.Parameters("@vintCurUserID").Value = mobjContext.UserId
        mcmdSaveForm.Parameters("@vintCurSysLID").Value = mobjContext.LanguageId
        mcmdSaveForm.Parameters("@vint{PRIMARY_KEY}").Value    = mintSelectedRecordID

        If (Err.Number <> 0) Then
          '::: Raise error that submitted data cannot be passed to the SP.
          mobjPageStatus.AddAppError gcintErrSpParameterAssignment
          '::: Append original VBScript error message for more info.
          mobjPageStatus.AddVbsError Err

        End If
        On Error Goto 0

        If (Not mobjPageStatus.HasErrors) Then
          '::: Execute the Delete SP, with error handling of course.
          On Error Resume Next
          '::: Syntax: cmd.Execute <RecAffected>, <Parameters>, <Options>
          mcmdSaveForm.Execute , , adExecuteNoRecords
          If (Err.Number <> 0) Then
            '::: Raise "Unable to delete data" error. Append ADO errors.
            mobjPageStatus.AddAppError gcintErrDataCouldNotBeDeleted
            mobjPageStatus.AddAdoErrors mconConnection.Errors

          End If
          On Error Goto 0

        End If

      End If  '::: Mode = SubmitDelete

    End If '::: Has Errors

    '::: -----------------------------------------------------------------
    '::: Re-Fetch Form Data
    '::: -----------------------------------------------------------------

    '::: If no errors have occurred, re-execute Get SP to retrieve the
    '::: data from the database. This will reflect the current state of
    '::: the data, including any changes that may have occurred through
    '::: logic on the back-end.
    If (Not mobjPageStatus.HasErrors) _
      And ((mobjPageStatus.Mode = gcintMode_SubmitEdit) _
      Or (mobjPageStatus.Mode = gcintMode_SubmitAdd)) Then

      '::: Get the record that was just edited or just inserted.
      mcmdGetForm.Parameters("@vint{PRIMARY_KEY}").Value = mintSelectedRecordID

      On Error Resume Next
      marecForm = OpenRecordsets(mcmdGetForm)
      If (Err.Number <> 0) Then
        '::: Error trying to fetch data. Append the ADO errors, raise a
        '::: critical "data could not be retrieved" error and end script.
        mobjPageStatus.AddAppError gcintErrDataCouldNotBeRetrieved
        mobjPageStatus.AddAdoErrors mconConnection.Errors
        mobjPageStatus.RaiseCriticalError

      End If
      On Error Goto 0

      If (mobjPageStatus.Mode <> gcintMode_FormAdd) Then
        '::: Check the record count. Exactly one record is expected.
        If (marecForm(0).RecordCount <> 1) Then
          '::: Raise critical "wrong record count" error and end script.
          mobjPageStatus.AddAppError gcintErrDataWrongRecordCount, "1", CStr(marecForm(0).RecordCount)
          mobjPageStatus.RaiseCriticalError

        End If

      End If

      '::: Apply newly fetched recordset to the form and copy data values
      '::: from recordset into form controls.
      Set mobjFormDataBinder.DataSource = marecForm(0)

      '::: If a row security violation is detected when bindng data,
      '::: an error is entered into PageStatus and RaiseCriticalError is called.
      mobjFormDataBinder.BindFromDataSource

    End If '::: Re-Fetch Form Data

    '::: -----------------------------------------------------------------
    '::: Raise Events
    '::: -----------------------------------------------------------------

    '::: Actions may be configured for this form's events.
    '::: If save was successful, raise the appropiate events.
    If (Not mobjPageStatus.HasErrors) Then
      RaiseEvents mcstrObjectName, mobjPageStatus.Mode, mctlForm, mobjContext

    End If

    '::: -----------------------------------------------------------------
    '::: Re-Adjust Mode
    '::: -----------------------------------------------------------------

    '::: Depending on the original submit mode, switch to the appropriate
    '::: non-submit mode for displaying the list form.
    ReadjustModeListForm mobjPageStatus, mobjResourceDict

  End If '::: End of Save Data

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Configure Form Elements
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: If form is in FormEdit mode, display Save(Edit) and Delete buttons.
  '::: If form is in FormAdd mode, display Save(Add) button.
  '::: In both cases, display the Cancel button.
  '::: Note that this could not be done earlier because the mode changes
  '::: after saving data during a form submit.
  Select Case mobjPageStatus.Mode

    Case gcintMode_FormEdit

      '::: Configure which form buttons should be displayed.
      mctlForm.SubmitEditButton.Visible     = True
      mctlForm.SubmitDeleteButton.Visible   = True
      mctlForm.SubmitCancelButton.Visible   = True

    Case gcintMode_FormAdd

      '::: Configure which form buttons should be displayed.
      mctlForm.SubmitAddButton.Visible    = True
      mctlForm.SubmitCancelButton.Visible = True

  End Select

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Create List
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: Prepare stored procedure to fetch data for the list.
  Set mcmdGetList = CreateSpCommand(mcstrSP_List, mconConnection)
  mcmdGetList.Parameters("@vintCurUserID").Value = mobjContext.UserId
  mcmdGetList.Parameters("@vintCurSysLID").Value = mobjContext.LanguageId
  mcmdGetList.Parameters("@vint{PAGE_KEY}").Value       = mobjPageStatus.PageKeys("{PAGE_KEY}")

  '::: Execute the stored procedure to retrieve data for the list.
  On Error Resume Next
  marecList = OpenRecordsets(mcmdGetList)
  If (Err.Number <> 0) Then
    '::: Error trying to fetch data. Append the ADO errors, raise a
    '::: critical "data could not be retrieved" error and end script.
    mobjPageStatus.AddAppError gcintErrDataCouldNotBeRetrieved
    mobjPageStatus.AddAdoErrors mconConnection.Errors
    mobjPageStatus.RaiseCriticalError

  End If
  On Error Goto 0

  '::: Create the list control.
  Set mctlList = NewObject("List", mobjContext)
  mctlList.ID = "lst{PAGE_NAME}"

  '::: Create a data binder for the list.
  Set mobjListDataBinder = NewObject("ListDataBinder", mobjContext)
  Set mobjListDataBinder.DataSource = marecList(0)
  Set mobjListDataBinder.List = mctlList
  Set mobjListDataBinder.PageStatus = mobjPageStatus
  mobjListDataBinder.Authorization.ObjectName = mcstrObjectName

  '::: Add ListKey(s). These are the fields in the ListDataBinder's
  '::: datasource recordset that uniquely identify a record in the
  '::: list. Fields already included in PageKeys cannot be added.
  mobjListDataBinder.ListKeys.Add "{PRIMARY_KEY}"

  '::: Set the currently selected value for the ListKey(s). With this
  '::: information, the ListDataBinder knows which record is selected.
  mobjListDataBinder.ListKeys("{PRIMARY_KEY}").SelectedValue = mintSelectedRecordID

  '::: and to configure the list columns appropriately.
  mobjListDataBinder.BindFromDataSource

  '::: Retrieve resource texts for column captions and list buttons
  AssignListResources mctlList, mobjResourceDict


':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Create Page Status Label
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: Create a label to display the page status.
  Set mctlPageStatusLabel = mobjPageStatus.CreateStatusLabel

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Dispose objects
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  '::: Tidy up and free resources. Some object references here may not
  '::: be valid but an error in this tidy up block can be ignored.
  On Error Resume Next

  '::: -----  List Objects -----
  Set mcmdGetList = Nothing
  Set mobjListDataBinder = Nothing
  marecList(0).Close
  Set marecList(0) = Nothing

  '::: -----  Form Objects -----
  Set mcmdGetForm = Nothing
  Set mcmdSaveForm = Nothing
  Set mobjFormDataBinder = Nothing
  marecForm(0).Close
  Set marecForm(0) = Nothing

  On Error Goto 0

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::  Render the Interface.
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%>
<html>
<head>
  <link rel="stylesheet" href="<%= mobjContext.ApplicationRootPath & mobjResourceDict("CssPath") %>">
  <script type="text/javascript" src="<%= mobjContext.ApplicationRootPath %>/system/ClientScript/ScrollScript.asp"></script>
  <title><% mobjResourceDict.RenderText "FormTitle" %></title>
</head>
<body>
<!-- -----------------------------------------------
     Page Header
------------------------------------------------ -->
<div id="PageHeader" class="PageHeader">
  <%
  '::: Display Banner.
  RenderBanner mobjContext, mconConnection

  %>
  <div class="EmployeeFormTitle" >
    <% mobjResourceDict.RenderText "FormTitle" %>
  </div>
</div>

<!-- -----------------------------------------------
     Page Body (scrolling)
------------------------------------------------ -->
<div id="PageBody" class="PageBodyList">
  <table cellpadding="2" cellspacing="0" style="width: 100%;" class="ListLayoutTable">
    <!-- table header -->
    <tr>
      <!-- The first column is for the buttons, therefore left-aligned.
           The scroll script only works if the first column is not wrapping.-->
      <th style="text-align: left; vertical-align: top; width: 5%;">&nbsp;</th>
      <!-- The following columns contain data, aligned depending on type. -->
      <!-- <th style="text-align: left; vertical-align: top; width: 5%;"><% mctlList.Columns("").RenderCaption %></th> -->
      {CREATE_HTML_TABLE_HEADER}
    </tr>
<%

'::: Loop through the rows in the list.
For Each mobjRow in mctlList.Rows
%>
    <!-- open table row -->
    <tr class="<%= mobjRow.CssClass %>">

      <!-- first column of table containing the button -->
      <td style="text-align: left; vertical-align: top; white-space: nowrap;">
<%

    '::: Check whether user is authorized to view the edit or add forms.
    '::: If so, then render the button for this row.
  mobjRow.Button.Render
%>
      </td>      
      <!-- columns containing data -->
      <!-- <td style="text-align: left; vertical-align: top"><% mobjRow.RenderField "" %></td>-->
      {CREATE_HTML_TABLE_CONTAIN_DATA}
    </tr>
<%
    '::: Check whether this is the currently selected row.
    '::: If so, check the permission to display the form and render it.
  If mobjRow.IsSelected Then
%>
    <tr>
      <td colspan="6" class="ListForm">
        <%
        '::: Render the opening <form> tag.
        mctlForm.BeginRender

        '::: Render hidden fields.
        mctlForm.GetControl("{PAGE_KEY}").Render
        mctlForm.GetControl("{PRIMARY_KEY}").Render
        %>
        <table class="FormLayoutTable">
          <colgroup>
            <col style="width:25%"></col>
			<col style="width:25%"></col>
            <col style="width:25%"></col>
			<col style="width:25%"></col>
          </colgroup>
		  {CREATE_HTML_TABLE_CONTAIN_DATA_SELECTED}
          <!-- 
          <tr>
            <td class="ControlLabel"><% mctlForm.GetControl("").RenderCaption %></td>
            <td><% mctlForm.GetControl("").Render %></td>
            <td class="ControlLabel"><% mctlForm.GetControl("").RenderCaption %></td>
            <td><% mctlForm.GetControl("").Render %></td>
          </tr>
          -->
          <tr>
            <td colspan="4" style="text-align:right;"><% mctlForm.RenderButtons %></td>
          </tr>        
        </table>
        <%
        '::: Render the closing <form> tag
        mctlForm.EndRender
        %>
      </td>
    </tr>
<%
  End If
Next '::: For each row in the list
%>
  </table>
</div>

<!-- -----------------------------------------------
     Page Footer
------------------------------------------------ -->
<div id="PageFooter" class="PageFooter">
  <%
  '::: Display page status label.
  mctlPageStatusLabel.Render

  '::: Render object help
  RenderObjectHelp mcstrObjectName, _
                   mobjContext, _
                   mconConnection
  %>
</div>
</body>
</html>